package com.objetdirect.gwt.umldrawer.client;

import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.Position;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.MessageBox;
import com.gwtext.client.widgets.Window;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.form.FormPanel;
import com.gwtext.client.widgets.form.TextField;
import com.gwtext.client.widgets.layout.FitLayout;

public class CreateProjectWindow extends Window {

	public CreateProjectWindow() {
		this.setTitle("Create New Project");
		this.setWidth(500);
		this.setHeight(100);
		this.setLayout(new FitLayout());
		this.setPaddings(5);
		this.setButtonAlign(Position.CENTER);
		this.setCloseAction(Window.HIDE);
		this.setPlain(true);
		this.setModal(true);
		
		FormPanel formPanel = new FormPanel();
		formPanel.setBaseCls("x-plain");
		formPanel.setLabelWidth(100);
		formPanel.setUrl("save-form.php");

		formPanel.setWidth(500);
		formPanel.setHeight(200);

		formPanel.add(new TextField("Project Name", "Name", 300));
		this.add(formPanel);
		
		Button createButton = new Button("Create");
		this.addButton(createButton);
		
		ButtonListenerAdapter createButtonAdapter = new ButtonListenerAdapter() {
			@Override
			public void onClick(Button button, EventObject e) {
				MessageBox.alert("Server Info", "Your Project Has Been Created!");
				hide();
			}
		};
		createButton.addListener(createButtonAdapter);
		
		Button cancelButton = new Button("Cancel");
		this.addButton(cancelButton);
		
		ButtonListenerAdapter cancelButtonAdapter = new ButtonListenerAdapter() {
			@Override
			public void onClick(Button button, EventObject e) {
				hide();
			}
		};
		cancelButton.addListener(cancelButtonAdapter);
		
		this.show();
	}
}
